<template>
  <div class="mod-tenant__tenant">
    <el-form :inline="true" :model="dataForm" @keyup.enter="getDataList()">
      <el-form-item>
        <el-input v-model="dataForm.appraisalTitle" placeholder="题名" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-input v-model="dataForm.fileNumber" placeholder="档号" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="getDataList()">{{ $t("query") }}</el-button>
      </el-form-item>
      <el-button type="primary"  @click="destroyed()">销毁</el-button>
    </el-form>
    <div style="width: 103%; height: 15px; background-color: rgb(240, 242, 245); margin: 0 -21px 15px"></div>
    <el-table ref="multipleTable" stripe v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" @sort-change="dataListSortChangeHandle" style="width: 100%">
      <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
      <el-table-column label="档案编号" prop="fileNumber" header-align="center" align="center"></el-table-column>
      <el-table-column label="题名" prop="destroyTitle" header-align="center" align="center"></el-table-column>
      <el-table-column label="档案类型" prop="categoryName" header-align="center" align="center"></el-table-column>
      <el-table-column label="销毁原因" prop="destroyReason" header-align="center" align="center"></el-table-column>
      <el-table-column label="销毁方式" prop="destroyWay" header-align="center" align="center"></el-table-column>
      <el-table-column label="销毁状态" prop="destroyState" header-align="center" align="center">
        <template v-slot="scope">
          <el-tag v-if="scope.row.destroyState == 0" size="small" type="success">待销毁</el-tag>
          <el-tag v-if="scope.row.destroyState == 1" size="small" type="success">已销毁</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="销毁日期" prop="destroyDate" header-align="center" align="center"></el-table-column>
      <el-table-column label="创建日期" prop="createDate" header-align="center" align="center"></el-table-column>
      <el-table-column label="操作人" prop="creator" header-align="center" align="center"></el-table-column>
      <el-table-column label="监销人" prop="salePeople" header-align="center" align="center"></el-table-column>
    </el-table>
    <el-pagination style="padding: 0px 38%" :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total" layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle" @current-change="pageCurrentChangeHandle"> </el-pagination>
  </div>
</template>

<script lang="ts">
import useView from "@/hooks/useView";
import { defineComponent, reactive, toRefs } from "vue";
import baseService from "@/service/baseService";
export default defineComponent({
  setup() {
    const state = reactive({
      getDataListURL: "/archive/destroy/page",
      getDataListIsPage: true,
      dataForm: {
        fileNumber: "",
        appraisalTitle: ""
      }
    });

    return { ...useView(state), ...toRefs(state) };
  },
  methods: {
    destroyed(){
      baseService.put(`/archive/destroy/destroyed`,this.dataListSelections.map(item=>item.id)).then((res) => {
        console.log(res)
        if (res.code !== 0) {
          return this.$message.error(res.msg);
        }
        this.getDataList();
      });
    }
  }
});
</script>
